<script>
import outMain from "@/components/outMain.vue";
import { ElMessage, ElMessageBox } from "element-plus";
import { staffkpi } from "@/http/api";

export default {
  components: { outMain },
  name: "",
  data() {
    return {
      tableData: [],
      statusArr: [
        { label: "全部", value: "" },
        { label: "简历录入排序", value: "1" },
        { label: "沟通统计排序", value: "2" },
        { label: "签约合计排序", value: "3" },
        { label: "离职合计排序", value: "4  " },
        { label: "合作企业排序", value: "5  " },
      ],
      queryData: {
        time: "",
        order_type: "",
        page: 1,
        per_page: 20,
      },
      total: 0,
    };
  },
  props: {},
  setup() {},
  methods: {
    getTime(time) {
      const y = time.getFullYear();
      const m =
        time.getMonth() < 9 ? `0${time.getMonth() + 1}` : time.getMonth() + 1;
      const d = time.getDate() < 10 ? `0${time.getDate()}` : time.getDate();
      const str = `${y}-${m}-${d}`;
      return str;
    },
    getData() {
      let paramsData = { ...this.queryData };
      if (paramsData.time) {
        let start = this.getTime(paramsData.time[0]);
        let end = this.getTime(paramsData.time[1]);
        paramsData.time = start + "," + end;
      }
      staffkpi(paramsData).then((res) => {
        if (res.data.code == 1) {
          this.tableData = res.data.data;
          this.total = res.data.data.length;
        }
      });
    },
    detailFn(id, navId) {
      this.$router.push({
        path: "/staffListDetail",
        query: { id: id, navId: navId, page: this.queryData.page },
      });
    },
  },
  mounted() {},
  created() {
    this.queryData.page = Number(localStorage.getItem("boot_page")) || 1;

    this.getData();
  },
};
</script>
<template>
  <outMain>
    <div class="tableCont">
      <div class="tableName flexCont">
        <div>员工KPI统计（{{ total }}）</div>
      </div>
      <div class="tableSerch">
        <div class="serchLeft"></div>
        <div class="serchRight">
          <el-form class="flexCenter" :inline="true">
            <el-form-item>
              <el-select
                v-model="queryData.order_type"
                clearable
                @change="getData"
                placeholder="请选择排序方式"
              >
                <el-option
                  v-for="item in statusArr"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
            <el-form-item class="serchTime">
              <el-date-picker
                v-model="queryData.time"
                type="daterange"
                clearable
                @change="getData"
                range-separator="~"
                start-placeholder="开始时间"
                end-placeholder="结束时间"
              />
            </el-form-item>
            <btn value="搜索" @click="getData"></btn>
          </el-form>
        </div>
      </div>
      <el-table class="tableMain" :data="tableData" stripe style="width: 100%">
        <el-table-column
          prop="staff_user_name"
          show-overflow-tooltip
          label="员工姓名"
        />
        <el-table-column prop="jllr" show-overflow-tooltip label="简历录入" />
        <el-table-column prop="gtzj" show-overflow-tooltip label="沟通总计">
          <template #default="{ row }">
            <span
              :class="row.gtzj == 0 ? '' : 'linkText_'"
              @click="detailFn(row.staff_id, 4)"
            >
              {{ row.gtzj }}
            </span>
          </template>
        </el-table-column>
        <el-table-column prop="qyzj" show-overflow-tooltip label="签约总计" />
        <el-table-column prop="lzzj" show-overflow-tooltip label="离职总计" />
        <el-table-column prop="hzqy" show-overflow-tooltip label="合作企业">
          <template #default="{ row }">{{ row.hzqy }}</template>
        </el-table-column>
        <el-table-column prop="Name" width="80" label="操作">
          <template #default="{ row }">
            <div class="tableCtrl">
              <div class="greenText ctrlText" @click="detailFn(row.staff_id)">
                详情
              </div>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <div class="pageCont">
        <el-pagination
          v-model:currentPage="queryData.page"
          v-model:page-size="queryData.per_page"
          background
          layout="total, prev, pager, next, jumper"
          :total="total"
          @size-change="getData"
          @current-change="getData"
        />
      </div>
    </div>
  </outMain>
</template>
<style scoped lang="less"></style>
